package com.ddz.library.service

import android.app.ActivityManager
import android.content.Context
import com.ddz.library.JKLibrary

object ServiceUtils {
    fun isRunning(serviceClazz: Class<*>): Boolean {
        val activityManager =
            JKLibrary.context!!.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
        val runningServiceInfo = activityManager.getRunningServices(Int.MAX_VALUE)
        runningServiceInfo.forEach {
            if (it.service.className == serviceClazz.simpleName) {
                return true
            }
        }
        return false
    }
}